package com.aopcinemas.common.ui;

import java.util.Calendar;
import java.util.Date;

public class UIUtils {

    public static Date mergeDateAndTime(Date date, Date time) {
        if (date == null && time == null) {
            return null;
        }
        Calendar calendar = Calendar.getInstance();
        if (date != null) {
            calendar.setTime(date);
        }
        Calendar timeCalendar = Calendar.getInstance();
        if (time != null) {
            timeCalendar.setTime(time);
        }
        calendar.set(Calendar.HOUR_OF_DAY, timeCalendar.get(Calendar.HOUR_OF_DAY));
        calendar.set(Calendar.MINUTE, timeCalendar.get(Calendar.MINUTE));
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTime();
    }

}
